// 节流
export const throttle = (func, delay) => {
    let lastTime = 0;
    return function (...args) {
        let now = +new Date().getTime();
        if (now - lastTime >= delay) {
            func.apply(this, args)
            lastTime = now;
        }
    }
}

// 防抖
export function debounce(func,delay) {
    let timer = null;
    return function(...args){
        clearTimeout(timer)
        timer = setTimeout(() => {
            func.apply(this,args)
        }, delay);
    }
}